<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('资金落实记录列表')" />
    <th:block th:include="include :: bootstrap-select-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>项目名称：</label>
                                <input type="text" name="projectName"/>
                            </li>
                            <li>
                                <label>项目类型：</label>
                                <select name="projectType" th:with="type=${@dict.getType('eb_project_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>项目标签：</label>
                                <select id="projectLabel" name="projectLabel" th:with="type=${@dict.getType('eb_project_label')}" class="selectpicker" data-none-selected-text="所有" multiple>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>审批状态：</label>
                                <select name="investStatus" th:with="type=${@dict.getType('eb_approve_status')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset();$('#projectLabel').selectpicker('val',['noneSelectedText'])"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <!--<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="manage:invest:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="manage:invest:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="manage:invest:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="manage:invest:export">
                    <i class="fa fa-download"></i> 导出
                </a>-->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-select-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('manage:invest:edit')}]];
        var removeFlag = [[${@permission.hasPermi('manage:invest:remove')}]];
        var prefix = ctx + "manage/invest";

        var projectTypeDatas = [[${@dict.getType('eb_project_type')}]];
        var projectLabelDatas = [[${@dict.getType('eb_project_label')}]];
        var approveStatusDatas = [[${@dict.getType('eb_approve_status')}]];

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                detailUrl: prefix + "/detail/{id}",
                sortName: "updateTime",
                sortOrder: "desc",
                modalName: "资金落实记录",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'projectName',
                    title: '项目名称'
                },
                {
                    field: 'projectType',
                    title: '项目类型',
                    formatter: function(value, item, index) {
                        return $.table.selectDictLabel(projectTypeDatas, item.projectType);
                    }
                },
                {
                    field: 'projectLabel',
                    title: '项目标签',
                    formatter: function(value, item, index) {
                        var projectLabel = item.projectLabel;
                        var labelStr = "";
                        if (projectLabel) {
                            var labelArray = projectLabel.split(",");
                            for (var i=0; i < labelArray.length; i++) {
                                labelStr = labelStr + " " + $.table.selectDictLabel(projectLabelDatas, labelArray[i]);
                            }
                        }
                        return labelStr;
                    }
                },
                {
                    field: 'totalInvest',
                    align: 'right',
                    title: '总投资'
                },
                {
                    field: 'doneInvest',
                    align: 'right',
                    title: '累计投资'
                },
                {
                    field: 'investStatus',
                    title: '审批状态',
                    formatter: function(value, item, index) {
                        return $.table.selectDictLabel(approveStatusDatas, item.investStatus);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        var status = row.investStatus;
                        if (status == 10) {
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.projectId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-info btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="submitInvest(\'' + row.projectId + '\')"><i class="fa fa-plus"></i>上报</a>');
                        } else if (status == 20) {
                            actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.detailTab(\'' + row.projectId + '\')"><i class="fa fa-eye"></i>查看</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="withdrawInvest(\'' + row.projectId + '\')"><i class="fa fa-reply"></i>撤回</a>');
                        } else if (status == 30) {
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.projectId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-info btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="submitInvest(\'' + row.projectId + '\')"><i class="fa fa-plus"></i>上报</a>');
                        } else if (status == 40) {
                            actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.detailTab(\'' + row.projectId + '\')"><i class="fa fa-eye"></i>查看</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.projectId + '\')"><i class="fa fa-edit"></i>变更</a>');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function withdrawInvest(projectId) {
            $.modal.confirm("确定撤回该项目投资建设资金情况吗？", function() {
                $.operate.save(ctx + "manage/invest/withdraw", {'projectId':projectId});
            });
        }

        function submitInvest(projectId) {
            $.modal.confirm("确定上报该项目投资建设资金情况吗？", function() {
                $.operate.save(ctx + "manage/invest/submit", {'projectId':projectId});
            });
        }
    </script>
</body>
</html>